from fastapi import FastAPI
from pydantic import BaseModel
app=FastAPI()

class Item(BaseModel):
    name: str
    #description: Optional[str] = None
    price: float
    #tax: Optional[float] = None


@app.get('/')
def read_root():
    return {"msg":"welcome to fastapi"}

@app.get('/ver')
def read_version():
    return {
        "version":'1.0',
        "author" : 'wzy',
        "waht" : 'ewaimp'
    }
@app.post("/items/")
async def create_item(item: Item):
    item_dict = item.dict()
    if item.name:
        price_with_tax =item.name+ str(item.price)
        item_dict.update({"返回结果信息": price_with_tax})
    return item_dict


if __name__ == '__main__':
    import uvicorn
    uvicorn.run(app=app,host='0.0.0.0',port=8006, debug=True)


